package swings.others;

import listener.UndoKeyListener;

import javax.swing.*;
import javax.swing.undo.UndoManager;
import java.awt.*;

/**
 * @version V1.0
 * @Title:
 * @Package
 * @Description:
 * @author: runoob
 * @date:
 */
public class CommonJTextField extends JTextField {

    public CommonJTextField(){
        setField();
    }

    public CommonJTextField(int columns){
        super(columns);
        setField();
    }

    public void setField(){
        UndoManager undoManager = new UndoManager();
        this.getDocument().addUndoableEditListener(undoManager);
        this.addKeyListener(new UndoKeyListener(undoManager));
        this.setCaretColor(Color.WHITE);
    }

}
